package february.test_2_27;

import java.util.Arrays;
import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        int h = 0;
        int x = 1;
        for(int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);
        for(int i = 0; i < n; i++) {
            h += arr[i];
            x *= arr[i];
            if(h > x) {
                n = n - i;
                break;
            }
        }
        System.out.println(factorial(n));
    }
    public static int factorial(int n) {
        int x = 1;
        for(int i = 1; i <= n; i++) {
            x *= i;
        }
        return x;
    }
}
